new Vue({
  el: '#app',
  data: function () {
    return {
      sourceCode: "",
      result: "",
      submitLoading: false,
    }
  },
  methods: {
    isEmpty: function (val) {
      return val === undefined || val == null || val === ''
    },

    reset: function () {
      this.sourceCode = "";
      this.result = "";
    },

    submit: function () {
      this.submitLoading = true;
      const clz = {
        code: this.sourceCode
      };
      let that = this;
      $.post({
        url: '/api/car',
        data: clz,
        dataType: 'json',
        success: function (resp) {
          console.log(resp);
          that.result = that.isEmpty(resp.message) ? "没有输出" : resp.message;
          that.submitLoading = false;
        }
      });
    }
  }
});

